﻿using CatUtils.Utils.Currency;
using CatUtils.Utils.Currency.IoUtils;
using CatUtils.Utils.Enhance.ThreadTool;
using CatUtils.Utils.Helper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RabbitDownload.WebSite.Local.AutoPic
{
    internal class AutoPicHelper
    {
        /// <summary>
        /// 保存Sina图床系统的文件信息位置
        /// </summary>
        public static readonly string SainSystemTextPath = StaticValue.BinPath + "SinExe.txt";

        /// <summary>
        /// 执行代码，通过bat 上传图片到sina图床
        /// </summary>
        public void RunCommend(string BatName, string UploadFilePath)
        {
            string SinaExePath = FileHelper.ReadAllText(SainSystemTextPath);
            if (SinaExePath == "")
                PrintLog.ENoWrite("未配置SinaExe路径。");
            if (SinaExePath == "" || UploadFilePath == "")
            {
                return;
            }
            string Commend = $"{SinaExePath} {UploadFilePath}";
            if (SinaExePath == "")
                PrintLog.ENoWrite("未配置SinaExe路径。");
            FileHelper.WriteText($"{StaticValue.TempPath}{BatName}.bat", Commend, Encoding.Default);

            FloderHelper.OpenFloder($"{StaticValue.TempPath}{BatName}.bat");
            ThreadSleep.SetSecondClock(300);
        }
    }
}